package gui;


import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Main{
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				File font_file = new File("Fonts/DroidSans.ttf");
				Font font = null;
				try {
					font = Font.createFont(Font.TRUETYPE_FONT, font_file);
					setUIFont(new javax.swing.plaf.FontUIResource(font.deriveFont(14f)));
				} catch (FontFormatException | IOException e) {
					JOptionPane.showMessageDialog(null, 
							"Lỗi khi đang nạp Font hiển thị", "Thông báo", JOptionPane.ERROR_MESSAGE);
					return;
				}
				
				JFrame myFrame = new CustomJFrame();
				
				CustomJPanel mainPanel = new GUIHome(myFrame, 20);;
				myFrame.add(mainPanel, BorderLayout.CENTER);
				myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				myFrame.pack();
				myFrame.setLocationRelativeTo(null);
				JFrame.setDefaultLookAndFeelDecorated(false);
				myFrame.setVisible(true);
			}
		});
		
	}
	
	public static void setUIFont (javax.swing.plaf.FontUIResource f){
		Enumeration<Object> keys = UIManager.getDefaults().keys();
	    while (keys.hasMoreElements()) {
	    	Object key = keys.nextElement();
	    	Object value = UIManager.get(key);
	    	if (value != null && value instanceof javax.swing.plaf.FontUIResource)
	    		UIManager.put (key, f);
	    }
	} 
}


